//并查集 面向对象版本
#include <iostream>

class unite_set
{
public:
    //合并
    int unite(int a, int b);
    //寻找祖宗
    int finda(int a);
    //是否同伙
    bool rela(int a, int b);
    //构造
    unite_set();
    unite_set(unite_set& u);
    unite_set(int size);
    //析构
    ~unite_set() = default;
private:
    int l[100000] = {0};
    int size; //大小
};


int main()
{
    //大小为n 写入次数为m
    int n, m; std::cin >> n >> m;
    unite_set uu(n); //带有大小的初始化
    for (int i = 0; i < m; i ++)
    {
        //x和y相连
        int x, y; std::cin >> x >> y;
        if (uu.unite(x, y) != 0) std::cout << "error" << std::endl;
    }

    std::cout << "Input q to quit; a to find root; b to judge relationship." << std::endl;
    while (true)
    {
        char xxx; std::cin >> xxx;
        if (xxx == 'q') break;
        else if (xxx == 'a') 
        {
            std::cout << "which one?" << std::endl;
            int x; std::cin >> x;

            for ()
        }
        
    }
    return 0;
}